home *** CD-ROM | disk | FTP | other *** search
-
- ~4Dgifts/toolbox/src/exampleCode/i18n README
-
-
- This directory contains example source code dealing with
- internationalization and localization as well as draft
- copies of the IRIX Internationalization chapter (Primer.ps)
- for what will eventually be the Internationalization chapter
- of the "IRIX Systems Programming Guide" as well as a Nutshell
- (Nutshell.ps) guide as an attempt to supply a high-level
- description of the issues involved in internationalizing
- software.
-
- To successfully run the programs in this directory, you
- need to be running an O.S level of 5.* or higher, and
- need to have Motif 1.2 running and X11 R5.
-
- Some examples will also require installed images of
- intl.sw. See below for more details.
-
-
- See the Frequently Asked Questions i18n file located at
- ~4Dgifts/toolbox/FAQs/netfaqs/i18n-faq.
-
-
-
- xpg3_wchar :
-
- this is a sample code which shows two things
-
- 1) use of wide characters for string manipulation
- 2) XPG/3 way of doing message catalogs (the other
- interface of cataloging is MNLS).
-
- the sample code is supplied with Japanese and German
- catalogs under the directory jp and de respectively.
-
- to run the Japanese version :
-
- setenv XMODIFIERS @im=_XWNMO
- run xwnmo
- run iwsh or exterm
-
- setenv NLSPATH jp
- setenv LANG ja_JP.EUC
- xpg3_wchar japanese_input_string
-
- and for German
-
- setenv NLSPATH de
- setenv LANG de
- xpg3_wchar german_input_string
-
- do man catopen for full details on the location of catalogs.
- do man gencat for help on generating message catalogs.
-
- if the NLSPATH environment variable is not set, it
- will run in the default english mode.
-
- the program takes the input string and outputs two strings
- which are made of even and odd alphabets from the original
- string (not useful in real life, but shows how to manipulate
- wide character strings).
-
- mnls_wchar :
-
- this is similar to xpg3_wchar except that it uses mnls
- way of cataloging.
-
- the sample code is supplied with Japanese and German
- catalogs under the directory jp and de respectively.
-
- you will have to move (or copy) the file mnls_wchar.cat from these
- respective directories to
-
- /usr/lib/locale/de/LC_MESSAGES for German
- and to /usr/lib/locale/ja_JP.EUC/LC_MESSAGES for Japanese
-
- to run the Japanese version :
-
- setenv LANG ja_JP.EUC
- mnls_wchar japanese_input_string
-
- and for German
-
- setenv LANG de
- mnls_wchar german_input_string
-
-
- =======================================================================
-
- Message Catalogs for Internationalization :
- -------------------------------------------
-
- Apart from the text which appears on the user interface
- widgets, an internationalized application must display
- other texts like prompts, error messages in the native
- language. Message cataloging facility is commonly used for this
- type of intertionalization of strings.
-
- Message catalogs are compiled databases of strings. The application
- extracts all the strings from a locale dependent message catalog.
- Although these strings are commonly used for communication
- in the native language, they can be used for any purpose.
-
- On Irix, there are two different interfaces to message catalogs:
- MNLS and XPG/3. MNLS is AT&T's Multi National Language Support and
- XPG/3 is the X/Open Portability Guide, Issue 3, by X/Open, Ltd.
- Developers working on base system utilities will probably be
- using MNLS, whereas developers working on independent projects will
- be using XPG/3. In order to maximize portability, developers are
- encouraged to use XPG/3 if given a choice.
- Catalog generation is exclusively the task of localizers. But the
- developer must know the contents of the catalog in order to specify
- the number of a message to be used in the application. So in order
- to inform the localizer which strings to translate and how they
- should create a catalog, the application developer should provide
- a master catalog for the developer's locale.
-
- MNLS message catalogs
- ---------------------
-
- MNLS message catalogs are merely list of strings in a file, separated
- by new-lines. Strings are referenced by line number in the original
- source file. Adding strings to an existing catalog should only be done
- at the end of the file. Otherwise, applications already using this catalog
- will end up accessing different strings. The three functions
- pfmt, gettxt, and printf are sufficient for most applications in
- this interface. fmtmsg() a comprehensive formatter is also available.
-
- MNLS catalogs do not need to be specifically opened. The catalog can be
- set explicitly once, or it can be specified everytime a string is
- needed.
-
- When a file of message strings is ready to be compiled, run mkmsgs()
- and save the file in /usr/lib/locale/<locale>/LC_MESSAGES
- (for example <locale> for german could be de).
-
- following is an example German mnls message strings which needs to
- be compiled using mkmsgs
-
- Benutzung: %s Zeichenkette\n
- Kein freier Speicher mehr\n
- Fehler beim Erzeugen eines 'wide characters'\n
- Hier ist die Ausgabe :
-
- mnls_wchar is an example source which uses MNLS interface of catalog.
-
- XPG/3 message catalogs
- ----------------------
-
- XPG/3 message catalogs contains sets of numbered messages. The
- three functions catopen, catgets, and catclose, provide a simple
- mechanism for retrieving numbered strings from a plain text file.
- This interface requires that a catalog be opened before it is read.
-
- The XPG/3 catalogs are located using the environment variable NLSPATH.
- The man page on catopen() gives full details on the path.
-
- After creating the file with message strings, you need to compile them
- into a binary form using gencat() and save the file in the location
- where catopen() can find it (NLSPATH mentioned above).
-
- following is an example German xpg3 message strings which needs to
- be compiled using gencat
-
- $set 1
- 1 Benutzung: %s Zeichenkette\n
- 2 Kein freier Speicher mehr\n
- 3 Fehler beim Erzeugen eines 'wide characters'\n
- 4 Hier ist die Ausgabe :
-
- xpg3_wchar is an example source which uses XPG/3 interface of catalog.
-
- Wide Characters
- ---------------
-
- The example source also demonstrates another very useful concept
- in internationalized applications: the wide character.
- A wide character is a data object of type wchar_t, which holds the
- system's largest numerical code for a character. On Irix 5.* and
- beyond, the sizeof(wchar_t) is 4.
-
- Since the strings made of wide characters have all the characters of
- the same size, the string can be treated as an array, and the application
- can simply index into the array in order to manipulate it.
-
- Wide characters are not as space efficient as multibyte strings and
- applications which do not need to perform string editing may never
- use wchars.
-
- -----------------
- Yusuf Attarwala
- SGI - Applications.
- x 3-3342
-